]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
environment: Split out the prepare and cleanup animation code
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Fri, 5 Dec 2025 22:39:23 +0000 (23:39 +0100)
committerMarco Trevisan (Treviño) <mail@3v1n0.net>
Fri, 5 Dec 2025 22:44:57 +0000 (23:44 +0100)
We do the same twice, and it's not trivial code anymore, so let's
separate this into another function which returns the prepare and cleanup
functions

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3992>

js/ui/environment.js

index 8effcd240d8994312b2fac6b923199f70bb55290..64a2b4629d1377d9bcadb47d483f352225f1dfaf 100644 (file)
@@ -71,6 +71,19 @@ function _makeEaseCallback(params, cleanup) {
     };
 }
 
+function _makeEasePrepareAndCleanup() {
+    const prepare = () => {
+        global.compositor.disable_unredirect();
+        global.begin_work();
+    };
+    const cleanup = () => {
+        global.compositor.enable_unredirect();
+        global.end_work();
+    };
+
+    return {prepare, cleanup};
+}
+
 function _getPropertyTarget(actor, propName) {
     if (!propName.startsWith('@'))
         return [actor, propName];
@@ -128,14 +141,7 @@ function _easeActor(actor, params) {
         actor.set_easing_mode(params.mode);
     delete params.mode;
 
-    const prepare = () => {
-        global.compositor.disable_unredirect();
-        global.begin_work();
-    };
-    const cleanup = () => {
-        global.compositor.enable_unredirect();
-        global.end_work();
-    };
+    const {prepare, cleanup} = _makeEasePrepareAndCleanup();
     const callback = _makeEaseCallback(params, cleanup);
 
     // cancel overwritten transitions
@@ -209,14 +215,7 @@ function _easeAnimatableProperty(animatable, propName, target, params) {
     if (!actor?.mapped)
         duration = 0;
 
-    const prepare = () => {
-        global.compositor.disable_unredirect();
-        global.begin_work();
-    };
-    const cleanup = () => {
-        global.compositor.enable_unredirect();
-        global.end_work();
-    };
+    const {prepare, cleanup} = _makeEasePrepareAndCleanup();
     const callback = _makeEaseCallback(params, cleanup);
 
     // cancel overwritten transition